import Mock from "mockjs";
import smsEntity from "../model/sms.entity"


const smsInstance = new smsEntity();

// 获取短信设置列表
Mock.mock(
  RegExp("/mock/api/sms/list" + ".*"),
  "get",
  () => {
    return {
      code: 200,
      msg: "success",
      data: smsInstance.findAll(),
    };
  }
);

// 短信设置详情
Mock.mock(
  RegExp("/mock/api/sms/alisms_config_info" + ".*"),
  "get",
  () => {
    return {
      code: 200,
      msg: "success",
      data: smsInstance.findAll()[0],
    };
  }
);

// 编辑短信设置
Mock.mock(
  RegExp("/api/sms/alisms_config" + ".*"),
  "post",
  (request: any) => {
    let res = JSON.parse(request.body);
    smsInstance.update(res);
    return {
      code: 200,
      msg: "success",
      data: {},
    };
  }
);